<template>
  <el-dialog :visible.sync="visible" v-dialogDrag :title="title" class="tl-dialog" width="1200px" @open="open" @close="close" top="10px" :append-to-body="true" :modal-append-to-body="true">
    <div style="padding-bottom:10px">
      <!-- 查询界面 -->
      <tl-list-search ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false" :isDisplaySearch="false" v-if="isHeaderDisplay">
        <template slot="search">
        </template>
      </tl-list-search>
      <!-- 列表界面 -->
      <div>
        <!-- 列表选择 -->
        <div class="table-alert-div" ref="selector">
          <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
            <template slot="title">
              已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRows.length }}</a>项&nbsp;&nbsp;
              <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
            </template>
          </el-alert>
        </div>
        <!--表格渲染-->
        <el-table class="tl-table" ref="mainTable" :height="tableHeight" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
          <el-table-column type="selection" width="55px" fixed="left" v-if="isSingleSelect === false "> </el-table-column>
          <el-table-column prop="dispprojectid" label="项目" width="200px" sortable="custom" sort-by="projectid" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="invoiceno" label="发票号码" width="150px" sortable="custom" sort-by="invoiceno" align="right" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <!-- <el-table-column prop="dispcontractid" label="项目合同" width="200px" sortable="custom" sort-by="contractid" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column> -->
          <el-table-column prop="invoicemoney" label="开票金额" width="150px" sortable="custom" sort-by="invoicemoney" align="right" header-align="center" :formatter="moneyFormat" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="dispcategory" label="业务类型" width="100px" sortable="custom" sort-by="category" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="customername" label="客户名称" width="200px" sortable="custom" sort-by="customername" align="left" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="dispinvoicetype" label="发票类型" width="150px" sortable="custom" sort-by="invoicetype" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="invoicedate" label="开票日期" width="100px" sortable="custom" sort-by="invoicedate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="demand" label="开票要求" width="200px" sortable="custom" sort-by="demand" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="explain" label="开票说明" width="200px" sortable="custom" sort-by="explain" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="invoiceorgname" label="发票开具组织" width="200px" sortable="custom" sort-by="invoiceorgname" align="left" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="invoiceorgcode" label="发票开具组织编码" width="150px" sortable="custom" sort-by="invoiceorgcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="invoicedeptname" label="发票所属部门" width="200px" sortable="custom" sort-by="invoicedeptname" align="left" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="invoicedeptcode" label="发票所属部门编码" width="150px" sortable="custom" sort-by="invoicedeptcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="erpcode" label="客户ERP编号" width="120px" sortable="custom" sort-by="erpcode" align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="companyname" label="企业名称" width="200px" sortable="custom" sort-by="companyname" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="bankname" label="开户行名称" width="200px" sortable="custom" sort-by="bankname" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="bankaccount" label="银行账户" width="150px" sortable="custom" sort-by="bankaccount" align="right" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="taxno" label="税号" width="150px" sortable="custom" sort-by="taxno" align="right" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="companyaddress" label="企业地址" width="200px" sortable="custom" sort-by="companyaddress" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="receiver" label="收件人" width="100px" sortable="custom" sort-by="receiver" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="receivertel" label="收件人电话" width="150px" sortable="custom" sort-by="receivertel" align="right" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="companytel" label="联系电话" width="150px" sortable="custom" sort-by="companytel" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="mailaddress" label="邮寄地址" width="200px" sortable="custom" sort-by="mailaddress" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="couriernumber" label="快递单号" width="150px" sortable="custom" sort-by="couriernumber" align="right" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="dispcourier" label="快递方式" width="150px" sortable="custom" sort-by="courier" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <!-- <el-table-column prop="dispisinvoicereturn" label="签收单是否返回" width="150px" sortable="custom" sort-by="isinvoicereturn" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column> -->
          <el-table-column prop="maildate" label="寄出日期" width="100px" sortable="custom" sort-by="maildate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="iscancel" label="是否作废" width="100px" sortable="custom" sort-by="iscancel" align="center" header-align="center">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.iscancel === 1" type="danger">是</el-tag>
              <el-tag v-else type="success">否</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="oldinvoicecode" label="原发票号" width="150px" sortable="custom" sort-by="oldinvoicecode" align="right" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="oldcustomername" label="原客户名称" width="200px" sortable="custom" sort-by="oldcustomername" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="oldinvoicedate" label="原开票日期" width="120px" sortable="custom" sort-by="oldinvoicedate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="oldinvoicemoney" label="原开票金额" width="150px" sortable="custom" sort-by="oldinvoicemoney" align="right" header-align="center" :formatter="moneyFormat" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="reinvoicereason" label="重新开票原因" width="200px" sortable="custom" sort-by="reinvoicereason" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="oldnumber" label="原发票邮寄单号" width="150px" sortable="custom" sort-by="oldnumber" align="right" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="cancelreason" label="作废原因" width="200px" sortable="custom" sort-by="cancelreason" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <!-- <el-table-column prop="invoiceflag" label="开票标识" width="120px" sortable="custom" sort-by="invoiceflag" align="center" :show-overflow-tooltip="true"></el-table-column> -->
          <el-table-column prop="latestphase" label="最新阶段" width="100px" sortable="custom" sort-by="latestphase" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="dispstate" label="状态" width="80px" sortable="custom" sort-by="state" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <!-- <el-table-column prop="orgname" label="申请公司" width="200px" sortable="custom" sort-by="orgname" align="left" :show-overflow-tooltip="true"></el-table-column> -->
          <!-- <el-table-column prop="orgcode" label="申请公司编码" width="120px" sortable="custom" sort-by="orgcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column> -->
          <el-table-column prop="deptname" label="申请部门" width="200px" sortable="custom" sort-by="deptname" align="left" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="deptcode" label="申请部门编码" width="120px" sortable="custom" sort-by="deptcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="username" label="申请人" width="80px" sortable="custom" sort-by="username" align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="usercode" label="申请人工号" width="100px" sortable="custom" sort-by="usercode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="docdate" label="单据日期" width="100px" sortable="custom" sort-by="docdate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="submitdate" label="提交时间" width="200px" sortable="custom" sort-by="submitdate" align="center" header-align="center" :formatter="dateTimeFormat" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="docno" label="单据编号" width="120px" sortable="custom" sort-by="docno" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="dispflowid" label="审批流程" width="120px" sortable="custom" sort-by="flowid" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="description" label="备注" min-width="200px" align="left" header-align="left" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column prop="enabled" label="有效" width="100px" sortable="custom" sort-by="enabled" align="center" header-align="center">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.enabled === 1" type="success">是</el-tag>
              <el-tag v-else type="danger">否</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="80px" align="center" fixed="right" v-if="isSingleSelect === true">
            <template slot-scope="scope">
              <el-button type="text" icon="el-icon-finished" @click="doSelectData(scope.row[fieldDefaultKey])">选择</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 列表分页 -->
        <el-row class="pagebar" ref="pager">
          <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
        </el-row>
      </div>
    </div>
    <div slot="footer" class="dialog-footer" v-if="isSingleSelect === false">
      <el-button type="text" @click="doCancelEdit">取消</el-button>
      <el-button type="primary" @click="doConfirm">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
/** mixins */
import { mixin_ref_list } from '@tapui/mixins/mixin_ref_list'
/** 子组件 */
/** 工具类 */
import { queryDataCode } from '@tapui/api/dataCode'
import { getAction, putAction, postAction } from '@tapui/utils/http'
import { rmbFormat } from "../../../utils/calculation"
/** VUE配置 */
export default {
  name: 'TlPmInvoiceApplyRef',
  components: {},
  mixins: [mixin_ref_list],
  data() {
    return {
      description: '项目合同开票申请参照页面',
      // 默认Key字段名
      fieldDefaultKey: 'id',
      // 默认显示字段名
      fieldDefaultValue: 'name',
      // url配置
      url: {
        list: '/pm/invoiceApply/refList'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'createon',
        sord: 'desc'
      },
      // header显示
      isHeaderDisplay: true
    }
  },
  methods: {
    moneyFormat(row, column, cellValue, index) {
      return rmbFormat(row[column.property])
    }
  }
}
</script>

